﻿/** 
 * Description:商品管理 
 * Date:2011-7-17
 * Author:Along	
*/
package com.community.shopping.service.logic;

import java.util.List;
import com.community.shopping.dao.GoodsDao;
import com.community.shopping.dao.OrderItemDao;
import com.community.shopping.domain.Goods;
import com.community.shopping.domain.GoodsType;


public class GoodsManager {
	public GoodsDao goodsDao;
	/**
	 * @param goodsDao the goodsDao to set
	 */
	public void setGoodsDao(GoodsDao goodsDao) {
		this.goodsDao = goodsDao;
	}
	
	private OrderItemDao itemDao;
	/**
	 * @param itemDao the itemDao to set
	 */
	public void setItemDao(OrderItemDao itemDao) {
		this.itemDao = itemDao;
	}
	
	/**
	 * 保存一行Goods
	*/
	public void save(Goods goods){
		goodsDao.save(goods);
	}
	/**
	 * 删除一行Goods
	*/
	public void delete(Goods goods){
		goodsDao.delete(goods);
	}
	
	public List<?> getGoods() {  		
		 return goodsDao.getGoods(); 
		 }
	/**
	 * 根据条件下查询
	*/
	public List getGoods(String sql){
		return goodsDao.getGoods(sql);
	}
	
	/**
	 * 根据栏目查询
	*/
	public List getGoodsByType(GoodsType type){
		return goodsDao.getGoods("goodType.id='"+type.getId()+"'  order by sort");
	}
	
	public Goods getGoodsById(Integer id){
		return goodsDao.getGoodsById(id);
	}
	/**
	 * 根据条件下翻页查询
	*/
	public List getGoods(String sql,Page page){
		return goodsDao.getGoods(sql+" and status='1' ",page);
	}
	/**
	 * 根据条件下翻页查询热门商品
	*/
	public List getHotGoods(String sql,Page page,Integer num){
		return goodsDao.getHotGoods(sql+" and status='1' ",page,num);
	}
	
	
	public List queryGoodsSaleList(String hql,Page page)
	{
		return itemDao.getGoodsItem(hql,page);	
	}
	

}
